package com.qd.common.panda.domain.entity.space;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Optional;

/**
 * 订单详情
 *
 * @author sjk
 */
@Getter
@Setter
public class OrderSpaceTenantDTO {

    /**
     * 租赁开始时间
     */
    private String startDate;
    /**
     * 租赁结束时间
     */
    private String endDate;
    /**
     * 租赁天数
     */
    private Long days;
    /**
     * 租赁人车牌号
     */
    private String tenantNumber;
    /**
     * 车位号
     */
    private String spaceNumber;
    /**
     * 熊猫泊车车位号
     */
    private String sysSpaceNumber;
    /**
     * 日单价
     */
    @JsonIgnore
    private BigDecimal dayPrice;
    /**
     * 日单价
     */
    private String dayPriceStr;

    public String getDayPriceStr() {
        return Optional.ofNullable(dayPrice).orElse(new BigDecimal("0")).stripTrailingZeros().toPlainString();
    }

    public void freeData() {
        this.startDate = null;
        this.endDate = null;
        this.days = null;
        this.tenantNumber = null;
        this.spaceNumber = null;
        this.sysSpaceNumber = null;
        this.dayPriceStr = null;
        this.dayPrice = null;
    }
}
